# 123(数学公式, 没什么好说的)

def sum_l_r_bf(l, r):
    """暴力写法"""
    idx, num = 1, 1
    row = 1  # 可以把每次的123...看做一行, row表示行号
    flag = False
    res = 0
    while idx != r + 1:
        if flag:
            res += num
        if idx == l:
            flag = True
            res += num
        if num == row:
            row += 1
            num = 0
        num += 1
        idx += 1
    return res


if __name__ == '__main__':
    print(sum_l_r_bf(1, 1))
    print(sum_l_r_bf(1, 3))
    print(sum_l_r_bf(5, 8))
